package descubreperu.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import descubreperu.excepcion.DAOExcepcion;
import descubreperu.negocio.SeguridadAdministrador;

/**
 * Servlet implementation class RegistrarAdministradorServlet
 */
@WebServlet("/RegistrarAdministradorServlet")
public class RegistrarAdministradorServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistrarAdministradorServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	

		String nombre = request.getParameter("txtNombre");
		String paterno = request.getParameter("txtPaterno");
		String materno = request.getParameter("txtMaterno");
		String sexo = request.getParameter("txtSexo");
		String dni = request.getParameter("txtDni");
		String celular = request.getParameter("txtCelular");
		String email = request.getParameter("txtEmail");
		//NO TOCAR !!

System.out.println(nombre);
System.out.println(paterno);
System.out.println(materno);
System.out.println(sexo);
System.out.println(dni);
System.out.println(celular);
System.out.println(email);

//NO TOCAR !!

	SeguridadAdministrador neg = new SeguridadAdministrador();

	
	
		try {
			neg.insertarAdministrador(nombre, paterno, materno, sexo, dni, celular, email);
			request.setAttribute("MSG", "Gracias por registrarte");
			RequestDispatcher rd = request.getRequestDispatcher("/index.jsp");
			rd.forward(request, response);
			
			/*RequestDispatcher rd = request.getRequestDispatcher("/index.jsp");
			rd.forward(request, response);*/
		} catch (DAOExcepcion e) {
			// TODO Auto-generated catch block
			
			/*Assert.fail("Fallo: " + e.getMessage());*/
		}


	}
}
	


		
	


